已解决:No converter for XXX with preset Content

您所在的位置:网站首页 unicom application 已解决:No converter for XXX with preset Content

已解决:No converter for XXX with preset Content

2024-01-27 17:10| 来源: 网络整理| 查看: 265

业务场景:

导出excel、pdf文件后台报异常,但是文件可以正常导出和查看。

解决办法:

controller层返回值改为void

过程:

起因是导出excel文件,发现下载的excel文件无法正常打开,总是提示文件损坏,需要修复,于是在代码中加入了以下代码

//2007版本excel导出 response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");

文件可以正常打开了,内容也没问题,但是发现后台报错

exception [No converter for [class java.util.HashMap] with preset Content-Type 'vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=utf-8']

最后请教他人解决:controller层返回值改为void

@GetMapping("/exportExcel") public void exportPdf(HttpServletRequest request, HttpServletResponse response){ //导出实现 }


【本文地址】


今日新闻


推荐新闻


CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3